package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Shixi;
import com.ruoyi.system.service.IShixiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务一Controller
 * 
 * @author ruoyi
 * @date 2023-03-28
 */
@RestController
@RequestMapping("/system/shixi")
public class ShixiController extends BaseController
{
    @Autowired
    private IShixiService shixiService;

    /**
     * 查询任务一列表
     */
    @PreAuthorize("@ss.hasPermi('system:shixi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Shixi shixi)
    {
        startPage();
        List<Shixi> list = shixiService.selectShixiList(shixi);
        return getDataTable(list);
    }

    /**
     * 导出任务一列表
     */
    @PreAuthorize("@ss.hasPermi('system:shixi:export')")
    @Log(title = "任务一", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Shixi shixi)
    {
        List<Shixi> list = shixiService.selectShixiList(shixi);
        ExcelUtil<Shixi> util = new ExcelUtil<Shixi>(Shixi.class);
        util.exportExcel(response, list, "任务一数据");
    }

    /**
     * 获取任务一详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:shixi:query')")
    @GetMapping(value = "/{que}")
    public AjaxResult getInfo(@PathVariable("que") String que)
    {
        return success(shixiService.selectShixiByQue(que));
    }

    /**
     * 新增任务一
     */
    @PreAuthorize("@ss.hasPermi('system:shixi:add')")
    @Log(title = "任务一", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Shixi shixi)
    {
        return toAjax(shixiService.insertShixi(shixi));
    }

    /**
     * 修改任务一
     */
    @PreAuthorize("@ss.hasPermi('system:shixi:edit')")
    @Log(title = "任务一", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Shixi shixi)
    {
        return toAjax(shixiService.updateShixi(shixi));
    }

    /**
     * 删除任务一
     */
    @PreAuthorize("@ss.hasPermi('system:shixi:remove')")
    @Log(title = "任务一", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ques}")
    public AjaxResult remove(@PathVariable String[] ques)
    {
        return toAjax(shixiService.deleteShixiByQues(ques));
    }
}
